#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>

#define LEDON  1
#define LEDOFF 0

int main(int argc, char* argv[])
{
    if (argc != 3)
    {
        printf("./ledtest /dev/led  0 \r\n");
        return -1;
    }
    const char* filename = argv[1];
    
    //打开led驱动
    int fd = open(filename, O_RDWR);
    if (fd < 0)
    {
        printf(" file %s open failed \r\n", filename);
        return -2;
    }
    char databuffer[1];
    databuffer[0] = atoi(argv[2]);
    int retvalue = write(fd, databuffer, sizeof(databuffer));
    
    if (retvalue < 0)

    {
        printf("write falied \r\n");
        close(fd);
    }

    close(fd);

    return 0;
}



